package com.crm.utils;

import lombok.Data;

@Data
public class R<T> {
    private int code;
    private String msg;
    private T data;

    private String token;

    public R() {
    }

    public R ok(){
        this.setCode(200);
        this.setMsg("success");
        return this;
    }

    public  R okR(T data){
        this.setCode(200);
        this.setMsg("success");
        this.setData(data);
        return this;
    }

    public  R err(){
        this.setCode(500);
        this.setMsg("服务器错误");
        return this;
    }

    public  R errR(){
        this.setCode(500);
        this.setMsg("账户或密码有误");
        return this;
    }

    public R(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
